package com.maolong.fenkufenbiaotest.controller;

import com.maolong.fenkufenbiaotest.pojo.ProdDetail;
import com.maolong.fenkufenbiaotest.service.ProdDetailService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.List;

@RestController
@Slf4j

public class ProdDetailController {
    @Autowired
    private ProdDetailService prodDetailService;

    @GetMapping("/list")
    public List<ProdDetail> list(){
        return prodDetailService.getProdDetailsByMonth(new Date());
    }

    @PostMapping("/add")
    public void add(ProdDetail prodDetail){
        log.info("add prodDetail:{}",prodDetail);
        ProdDetail prodDetail1 = new ProdDetail();
        prodDetail1.setName("ahahhahahahha");
        prodDetail1.setAddTime(new Date());
        prodDetailService.addProdDetail(prodDetail1);
    }

    @GetMapping("/page")
    public List<ProdDetail> page(){
        return prodDetailService.selectByPage();
    }

}
